package com.firesrc.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import jodd.cache.Cache;
import jodd.db.pool.CoreConnectionPool;

import org.h2.tools.Server;

import com.firesrc.bean.Record;
import com.firesrc.db.DBManager;

public abstract class SuperServlet extends HttpServlet {
	private static final long serialVersionUID = 4414487868867691412L;
	private Server server = null;
	protected Cache<String, Record> cache;
	protected CoreConnectionPool cp = null;

	@Override
	public void init() throws ServletException {
		super.init();
		startDB();
		startThread();
	}

	private void startThread() {
		// AutoExecutorManager manager =
		// ScheduleExecutorManagerFactory.getAutoExecutorManager();
		// manager.start();
		// SuperScheduledExecutorManager searchMailExecutorManager =
		// ScheduleExecutorManagerFactory.getSearchMailExecutorManager();
		// searchMailExecutorManager.start();
		// FetchKeywordExecutorManager fetchKeywoed =
		// ScheduleExecutorManagerFactory.getFetchKeywordExecutorManager();
		// fetchKeywoed.start();

	}

	public void startDB() {
		// try {
		// // server = Server.createTcpServer().start();
		// // } catch (SQLException e) {
		// System.out.println("服务器已经启动 :SuperServlet.init()");
		// }
		// cp = DBManager.getPublicConnectionPool();
	}

	@Override
	public void destroy() {
		cp.close();
		server.stop();
		super.destroy();
	}
}